<?php

declare(strict_types=1);

namespace app\common\model\sys;

use think\Model;
use app\common\traits\ModelTrait;

/**
 * 系统节点菜单
 * 作者：kaige
 * 时间: 2022-04-05
 * 基于开源系列修改
 */
class SysMenu extends Model
{
    //开启自动写入时间戳字段
    protected $autoWriteTimestamp = true;
    protected $createTime = 'create_time';
    protected $updateTime = 'update_time';

    // 设置字段信息(能减少查询一次)
    protected $schema = [
        'id'            => 'int',
        'is_sys'        => 'int',
        'is_lock'       => 'int',
        'menu_id'       => 'string',
        'p_menu_id'     => 'string',
        'type'          => 'string',
        'menu_type'     => 'int',
        'title'         => 'string',
        'name'          => 'string',
        'node'          => 'string',
        'params'        => 'string',
        'icon'          => 'string',
        'open_type'     => 'int',
        'is_left'       => 'int',
        'width'         => 'string',
        'height'        => 'string',
        'is_max'        => 'int',
        'is_menu'       => 'int',
        'is_auth'       => 'int',
        'is_login'      => 'int',
        'status'        => 'int',
        'is_extend'     => 'int',
        'sort'          => 'int',
        'create_time'   => 'int',
        'update_time'   => 'int',
    ];

    // 定义字段对应表单类型、属性
    protected $formItem = [
        'id'            => [
            'label'=> 'ID',
            'type' => 'input',
            'hide' => true,
            'required' => false,
            'readonly' => false,
            'disabled' => false,
            'reqtext'=> ''
        ],
        'is_sys'        =>  [
            'label'=> '是否系统',
            'type' => 'checkbox',
            'hide' => false,
            'required' => false,
            'readonly' => false,
            'disabled' => false,
            'reqtext'=> ''
        ],
        'is_lock'       =>  [
            'label'=> '是否锁定',
            'type' => 'checkbox',
            'hide' => false,
            'required' => false,
            'readonly' => false,
            'disabled' => false,
            'reqtext'=> ''
        ],
        'menu_id'       =>  [
            'label'=> '菜单ID',
            'type' => 'input',
            'hide' => false,
            'required' => false,
            'readonly' => false,
            'disabled' => false,
            'reqtext'=> ''
        ],
        'p_menu_id'     =>  [
            'label'=> '菜单父ID',
            'type' => 'input',
            'hide' => false,
            'required' => false,
            'readonly' => false,
            'disabled' => false,
            'reqtext'=> ''
        ],
        'type'          =>  [
            'label'=> '类型',
            'type' => 'checkbox',
            'hide' => false,
            'required' => false,
            'readonly' => false,
            'disabled' => false,
            'reqtext'=> ''
        ],
        'menu_type'     =>  [
            'label'=> '是否锁定',
            'type' => 'select',
            'select' => [
                ['name' => '无','value'=> 0],
                ['name' => '弹窗','value'=> 1],
                ['name' => 'TAB任务栏','value'=> 2],
            ],
            'hide' => false,
            'required' => false,
            'readonly' => false,
            'disabled' => false,
            'reqtext'=> ''
        ],
        'title'         =>  [
            'label'=> '是否锁定',
            'type' => 'input',
            'hide' => false,
            'required' => false,
            'readonly' => false,
            'disabled' => false,
            'reqtext'=> ''
        ],
        'name'          =>  [
            'label'=> '是否锁定',
            'type' => 'input',
            'hide' => false,
            'required' => false,
            'readonly' => false,
            'disabled' => false,
            'reqtext'=> ''
        ],
        'node'          =>  [
            'label'=> '是否锁定',
            'type' => 'input',
            'hide' => false,
            'required' => false,
            'readonly' => false,
            'disabled' => false,
            'reqtext'=> ''
        ],
        'params'        =>  [
            'label'=> '是否锁定',
            'type' => 'input',
            'hide' => false,
            'required' => false,
            'readonly' => false,
            'disabled' => false,
            'reqtext'=> ''
        ],
        'icon'          =>  [
            'label'=> '是否锁定',
            'type' => 'input',
            'hide' => false,
            'required' => false,
            'readonly' => false,
            'disabled' => false,
            'reqtext'=> ''
        ],
        'open_type'     =>  [
            'label'=> '是否锁定',
            'type' => 'input',
            'hide' => false,
            'required' => false,
            'readonly' => false,
            'disabled' => false,
            'reqtext'=> ''
        ],
        'is_left'       =>  [
            'label'=> '是否锁定',
            'type' => 'checkbox',
            'hide' => false,
            'required' => false,
            'readonly' => false,
            'disabled' => false,
            'reqtext'=> ''
        ],
        'width'         =>  [
            'label'=> '是否锁定',
            'type' => 'input',
            'hide' => false,
            'required' => false,
            'readonly' => false,
            'disabled' => false,
            'reqtext'=> ''
        ],
        'height'        =>  [
            'label'=> '是否锁定',
            'type' => 'input',
            'hide' => false,
            'required' => false,
            'readonly' => false,
            'disabled' => false,
            'reqtext'=> ''
        ],
        'is_max'        =>  [
            'label'=> '是否锁定',
            'type' => 'checkbox',
            'hide' => false,
            'required' => false,
            'readonly' => false,
            'disabled' => false,
            'reqtext'=> ''
        ],
        'is_menu'       =>  [
            'label'=> '是否锁定',
            'type' => 'checkbox',
            'hide' => false,
            'required' => false,
            'readonly' => false,
            'disabled' => false,
            'reqtext'=> ''
        ],
        'is_auth'       =>  [
            'label'=> '是否锁定',
            'type' => 'checkbox',
            'hide' => false,
            'required' => false,
            'readonly' => false,
            'disabled' => false,
            'reqtext'=> ''
        ],
        'is_login'      =>  [
            'label'=> '登录访问',
            'type' => 'checkbox',
            'hide' => false,
            'required' => false,
            'readonly' => false,
            'disabled' => false,
            'reqtext'=> ''
        ],
        'status'        =>  [
            'label'=> '状态',
            'type' => 'checkbox',
            'hide' => false,
            'required' => false,
            'readonly' => false,
            'disabled' => false,
            'reqtext'=> ''
        ],
        'is_extend'     =>  [
            'label'=> '是否展开',
            'type' => 'checkbox',
            'hide' => false,
            'required' => false,
            'readonly' => false,
            'disabled' => false,
            'reqtext'=> ''
        ],
        'sort'          =>  [
            'label'=> '排序',
            'type' => 'input',
            'hide' => false,
            'required' => false,
            'readonly' => false,
            'disabled' => false,
            'reqtext'=> ''
        ]
    ];

    use ModelTrait;
}
